﻿using System.Linq;
using System;
namespace HB.Expand
{
    /// <summary>
    /// 包含类拓展方法
    /// </summary>
    public static class ContainBy
    {
        /// <summary>
        /// 是否被指定的数组包含
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public static bool IsContainBy<T>(this T data, params T[] list) /*where T : struct,Nullable*/
        {
            return list.Contains(data);
        }
        /// <summary>
        /// 字符串包含检查，可指定大小写
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="findText"></param>
        /// <param name="ignorecase"></param>
        /// <returns></returns>
        public static bool Contain<T>(this string data, string findText, bool ignorecase = false) where T : struct
        {
            return data.IndexOf(findText, ignorecase ? System.StringComparison.OrdinalIgnoreCase : System.StringComparison.Ordinal) > 0;
        }

    }
}
